<template>
  <div class="legal-code-input-wrap">
    <el-input v-model="selectData" placeholder="请输入合同编号" />
    <span class="get-code-btn" @click="getCode">{{ isAutoCode? '手动填写' : '自动生成' }}</span>
  </div>
</template>
<script>
export default {
  name: 'LegalCodeInput',
  model: {
    prop: 'params',
    event: 'change'
  },
  props: {
    params: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      isAutoCode: false
    };
  },
  computed: {
    selectData: {
      get() {
        return this.params;
      },
      set(val) {
        this.$emit('change', val);
      }
    }
  },
  methods: {
    getCode() {
      if (this.isAutoCode) {
        this.isAutoCode = true;
      } else {
        this.isAutoCode = false;
        this.selectData = '99999';
      }
    }
  }
};
</script>
<style lang="scss" scoped>
.legal-code-input-wrap {
  display: flex;
  align-items: center;
  .get-code-btn {
    margin-left: 16px;
    cursor: pointer;
    color: #406EFF;
    font-size: 14px;
  }
}
</style>
